/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SensorImpl;

import SensorInterface.ISensor;
import CommonValue.Wind;
import DTO.SensorDTO;
import java.util.Random;

public class WindSensor extends BaseSensor implements ISensor {

    private static int count; // number of this sensor type

    public WindSensor(String location) {
        count++;
        setNumber(count);
        setSensorSign(Wind.SIGN);
        setLocation(location);
    }

    @Override
    public SensorDTO generateData() {
        SensorDTO sdto = new SensorDTO(getSensorSign(),getNumber(),getLocation());
        Random rd = new Random();
        float f = rd.nextInt(120) + rd.nextInt(40) + rd.nextFloat();
        sdto.addData(Wind.SPEED, f);
        f = (float) rd.nextInt(360);
        sdto.addData(Wind.DIRECTION, f);
        return sdto;
    }

    @Override
    public void printData(SensorDTO sdto) {
        if (isMatchSign(sdto)) return;
        System.out.println(Wind.SPEED + " : "+ sdto.getData().get(Wind.SPEED));
        System.out.println(Wind.DIRECTION + " : "+ sdto.getData().get(Wind.DIRECTION));
    }
}